package itesm.coler.cloudsql;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import com.google.appengine.api.rdbms.AppEngineDriver;

public class ConnectDB {
	
	private Connection connectionDB = null;

	//Constructor que define una conexion a la instancia en cloud sql
	public ConnectDB() throws ClassNotFoundException, SQLException{
	DriverManager.registerDriver(new AppEngineDriver());
	connectionDB = DriverManager.getConnection("jdbc:google:rdbms://wavecolersql:wavecoler/wavecolertest");
	}
	public ConnectDB(String driver) throws ClassNotFoundException{
		Class.forName(driver);
		//holo
	}
	
	public Connection getConnectionDB(){
		return connectionDB;
	}
	
	public void setConnectionDB(Connection connectionDB){
		this.connectionDB = connectionDB;
	}
	
	public void closeConnectionDB(){
		if(connectionDB!=null){
			try{
				connectionDB.close();
			}catch(SQLException e){
				e.printStackTrace();
			}
		}
	}
	
}
